package com.chazz.service.impl;

import com.chazz.dao.impl.DiscountDaoImpl;
import com.chazz.service.IsDiscountService;

/**
 * description: IsDiscountDaoImpl IsDiscountDao的是实现类 <br>
 * date: 2020/9/22 9:20 <br>
 * author: Chazz <br>
 * version: 1.0 <br>
 */
public class IsDiscountServiceImpl implements IsDiscountService {
    /**
     * description: afterDiscount 返回折扣之后的的小计价格 <br>
     * version: 1.0 <br>
     * date: 2020/9/22 9:37 <br>
     * author: Chazz <br>
     * @param categoryId 分类id
     * @param count 商品数量
     * @return double 商品计算折扣之后的小计价格
     */ 
    @Override
    public double afterDiscount(Integer categoryId, Integer count,Double price) {
        double  Dcount = count;
        DiscountDaoImpl discountDao = new DiscountDaoImpl();
        Double discount = discountDao.selectDiscountById(categoryId);
        Double totalPrice = discount*price*Dcount;
//        try {
//            int i = Db.use().insert(Entity.create("orders").set("tatolprice", totalPrice));
//        } catch (SQLException throwables) {
//            throwables.printStackTrace();
//        }
        return totalPrice;
    }
}
